/*
Copyright © 2024 NAME HERE <EMAIL ADDRESS>
*/
package cmd

import (
	"github.com/rs/zerolog/log"
	"github.com/spf13/viper"
	"kvmc/app"

	"github.com/spf13/cobra"
)

// listCmd represents the list command
var listCmd = &cobra.Command{
	Use:     "list",
	Aliases: []string{"ls"},
	Short:   "展示配置信息",
	Long:    ``,
	Args: func(cmd *cobra.Command, args []string) error {
		return nil
	},
	Run: func(cmd *cobra.Command, args []string) {
		manager, err := app.NewManager(viper.GetString("configPath"))
		if err != nil {
			log.Err(err).Send()
			return
		}
		manager.List(listOpt)
	},
}

var listOpt = new(app.ListOption)

func init() {
	rootCmd.AddCommand(listCmd)
	listCmd.Flags().StringVarP(&listOpt.ClusterName, "cluster", "c", "", "node的集群名称")
	listCmd.Flags().BoolVarP(&listOpt.All, "all", "A", false, "显示所有集群的node")
}
